<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-05-05 22:02:56
 * @LastEditors: lz
 * @LastEditTime: 2022-01-07 22:53:12
-->
<template>
  <div ref="right1_container" style="height: 95%"></div>
</template>
<script>
import { Line } from '@antv/g2plot';
import {get} from '../../../utils/request'
import moment from 'moment'
export default {
  data(){
    return{
      dataArr:[]
     }
  },
  mounted(){
   this.initData()
  },
  methods:{
    initData(){
      get('/dashboard/pageQueryTodayData',{
        page:1,
        pageSize:5,
        device_id:1
      }).then(res=>{
        res.data.list.forEach(item => {
          item.dataTime = moment(item.insert_time).format('HH:mm')
        });
        this.dataArr=res.data.list;
        console.log(6666,res)
        this.initChart();
      })
    },
    initChart(){
   
     const line = new Line(this.$refs.right1_container,{
       data:this.dataArr,
       xField:'dataTime',
       yField:'humidity'
     });
    
     line.render();
    }

  }
}
</script>
<style scoped>

</style>